package com.example.fill;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Shader;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;

public class V24111 extends View {
    public V24111(Context context) {
        super(context);

    }

    public V24111(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public V24111(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public V24111(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        int colorBg = ContextCompat.getColor(getContext(), R.color.md_theme_dark_onPrimary);
        int[] colors = {ColorUtils.toAlpha(colorBg, 0.01f), ColorUtils.toAlpha(colorBg, 0.25f), ColorUtils.toAlpha(colorBg, 0.01f)};
        float[] positions = {0, 0.5f, 1};
        LinearGradient linearGradient = new LinearGradient(0, 0, 0, getMeasuredHeight(), colors, positions, Shader.TileMode.CLAMP);
        paint.setShader(linearGradient);
    }

    private Paint paint = new Paint();
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        canvas.drawRect(0,0,getWidth(),getHeight(),paint);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        invalidate();
        return super.onTouchEvent(event);
    }
}
